<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">  
  <title>订单列表</title>
 </head>
 <body>
 
 <?php
  require_once('inc_admin.php');
  connect();
  //编写sql语句
  $sql = 'select * from wyyorders a1 left join wyyuser a2 on a1.wyyuserid=a2.wyyid left join wyyproduct a3 on a1.wyyitemid=a3.wyyid';
  //echo $sql.'<br/>';  
  $result = fetch_array($sql); 
   
 ?>
 <center><h3>订单列表</h3></center>
 <table align="center" width="80%" border=1> 
 <tr>
   <th>编号</th>
   <th>订单id</th>   
   <th>用户id</th>
   <th>产品id</th>
   <th>数量</th>
   <th>订单时间</th>
   <th>支付金额</th>
   <th>订单状态</th>
 </tr>

 <?php
  foreach ($result as $row) {
   echo '<tr>';
   
   echo '<td>'.$row['wyyid'].'</td>';
   echo '<td>'.$row['wyyusername'].'</td>'; 
   echo '<td>'.$row['wyyitemname'].'</td>'; 
   echo '<td>'.$row['wyyitemnum'].'</td>'; 
   echo '<td>'.$row['wyypay'].'</td>'; 
   echo '<td>'.$row['wyyordertime'].'</td>'; 
   echo '<td>'.$row['wyyorderstate'].'</td>';
     if($row['wyyorderstate']==0)
  {
    $row['wyyorderstate']='待发货';
  }
 
   if($row['wyyorderstate']==1)
  {
    $row['wyyorderstate']='已取消';
  }
   if($row['wyyorderstate']==2)
  {
    $row['wyyorderstate']='已收货';
  }
 

   echo '<td>
      <a href="editorder.php?id='.$row['wyyid'].' ">修改</a>|     
      <a href="deliver.php?id='.$row['wyyid'].' ">发货</a> | 
      <a href="cancelorder.php?id='.$row['wyyid'].' ">取消</a> | 
   
      <a href="delorder.php?id='.$row['wyyid'].'" onClick="return confirm(\'确定要删除吗？\');">删除</a></td>';
   echo '</tr>';  
  }
  echo '</table>';  
  $totalrows = count($result);
  echo "<table align='center'><tr><td>共有{$totalrows}条记录</td></tr></table>";   
 ?>
 
 </body>
</html>
